<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<title>示例信息查询</title>
<style type="text/css">
  form {
    display: inline;
  }
  table {
    border-collapse: collapse;
    border: solid 1px;
    width: 480px;
  }
  td {
    border: 1px solid;
    text-align: center;
  }
</style>
</head>
<body>
<c:if test="${requestScope['boolean']!=null}">
  <%response.sendRedirect("query.test");%>
</c:if>
<div align="center">
<fieldset>
  <legend>添加数据</legend>
  <form action="add.test" method="post">
    <input type="text" name="param" placeholder="唯一值">
    <button>提交</button>
  </form>
</fieldset>
  <form method="post" action="query.test">
    <input type="text" name="kw" placeholder="关键词">
    <input type="submit" value="查询">
  </form>
  <c:if test="${requestScope.entities.size()>0}">
    <table style="border: 1px black solid;">
      <tr>
        <th width="50">字段1</th>
        <th>字段2</th>
        <th colspan="2">操作</th>
      </tr>
      <c:forEach items="${requestScope.entities}" var="obj">
        <tr>
          <td>${obj.field1}</td>
          <td>
            <form id="${obj.field1}" action="<c:url value="modify.test"/>" method="post">
              <input type="hidden" name="key" value="${obj.field1}" readonly>
              <input type="text" name="unique_value" value="${obj.field2}" placeholder="唯一值">
            </form>
          </td>
          <td>
            <button onclick="document.getElementById('${obj.field1}').submit()">修改</button>
          </td>
          <td>
            <form action="remove.test" method="post">
              <input type="hidden" name="id" value="${obj.field1}" readonly>
              <button>删除</button>
            </form>
          </td>
        </tr>
      </c:forEach>
    </table>
  </c:if>
</div>
</body>
</html>
